package inet.app.controller.request;

import inet.app.model.util.AESEncryption;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Request {

	public final static String URL_LOGIN = "http://id.inet.vn/checkLoginInfoApp";

	public String getkqxsbyregion(String date, String region) {
		String request = "http://appsrv.sms.vn/app/xs?action=getkqxsbyregion"
				+ "&date=" + date + "&region=" + region;
		return request;
	}

	public String getkqxs(String code, String sdate, String edate) {
		String request = "http://appsrv.sms.vn/app/xs?action=getkqxs"
				+ "&code=" + code + "&sdate=" + sdate + "&edate=" + edate;
		return request;
	}

	public String getxsdttt(String date) {
		String request = "http://appsrv.sms.vn/app/xs?action=getxsdttt"
				+ "&date=" + date;
		return request;
	}

	public String gettk(String code, String numberdate, String couple) {
		String request = "http://appsrv.sms.vn/app/xs?action=tk" + "&code="
				+ code + "&numberdate=" + numberdate + "&couple=" + couple;
		return request;
	}

	public String getsomo() {
		String request = "http://appsrv.sms.vn/app/xs?action=somo";
		return request;
	}

	public String getlisttinhsc(String date) {
		String request = "http://appsrv.sms.vn/app/xs?action=listtinhsc"
				+ "&date=" + date;
		return request;
	}

	public String getkqsc(String action, String code) {
		String request = "http://appsrv.sms.vn/app/xs?action=" + action
				+ "&code=" + code;
		return request;
	}

	public String gettkdb(String select) {
		String request = "http://appsrv.sms.vn/app/xs?action=tkdb" + "&select="
				+ select;
		return request;
	}

	public String getdoso(String code, String couple) {
		String request = "http://appsrv.sms.vn/app/xs?action=doso&code=" + code
				+ "&couple=" + couple;
		return request;
	}

	public String getsctv(String action, String code) {
		String request = "http://appsrv.sms.vn/app/xs?action=" + action
				+ "&code=" + code;
		return request;
	}

	public String getusrlogin(String usr, String pwd) {
		String request = "http://appsrv.sms.vn/app/xs?action=usrlogin"
				+ "&usr=" + usr + "&pwd=" + pwd;
		return request;
	}

	public String getusractive(String usr, String activecode) {
		String request = "http://appsrv.sms.vn/app/xs?action=usractive"
				+ "&usr=" + usr + "&activecode=" + activecode;
		return request;
	}

	public String getusrreg(String usr, String pwd, String mobile, String email) {
		String request = "http://appsrv.sms.vn/app/xs?action=usrreg" + "&usr="
				+ usr + "&pwd=" + pwd + "&mobile=" + mobile + "&email=" + email;
		return request;
	}

	public String getLogin(String usrname, String pwd) {
		String request = "http://id.inet.vn/checkLoginInfoApp?user=%s&pass=%s";
		try {
			String passEncrypt = URLEncoder.encode(
					AESEncryption.encrypt(pwd, AESEncryption.KEY_AES), "utf-8");
			request = String.format(request, usrname, passEncrypt);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			request = null;
		}
		return request;
	}

	public String getRegister(String fullname, String user, String email,
			String mobile, String pass) {
		String request = "http://id.inet.vn/checkRegister?fullname=%s&user=%s&email=%s&mobile=%s&pass=%s";
		try {
			String passEncrypt = URLEncoder
					.encode(AESEncryption.encrypt(pass, AESEncryption.KEY_AES),
							"utf-8");
			request = String.format(request, fullname, user, email, mobile,
					passEncrypt);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			request = null;
		}
		return request;
	}

}
